#include <stdlib.h>
#include <stddef.h>
#include "DIALOG.h"
#include "\src\mzhxj.h"
#include "Target\2410lib.h"
#include "Target\option.h"
#include "Target\2410addr.h"
#include "Target\timer.h"
#include "mmu\mmu.h"
#include "\gui\widget\framewin.h"

/*******************************************************************
*
*                 main
*
********************************************************************
*/

#include "SPI.h"
#include "stdio.h"

int i,j;
char buf[100];


void Main(void)
{
    MMU_Init();
    ChangeClockDivider(1,1);          // 1:2:4
    ChangeMPllValue(0xa1,0x3,0x1);    // FCLK=202.8MHz     
    Port_Init();
    GUI_Init();

///////////////////////////////////////////////////////////////

	SPI0_Init(SPI_SMOD_POL | SPI_BIT_ENSCK | SPI_BIT_MSTR | SPI_BIT_GPOL | SPI_BIT_GPHA,
	           1000000);

// Transfer data 10 times to init device.
for(i=0; i<10; i++)
	SPI0_Transfer(0xff);

// Set Port to select device here.

	           
	j = 0;
	while(1)
	{
		i = SPI0_Transfer(0xff);
		if( i != j)
		{
			j = i;
			sprintf(buf,"data was: %4d",j);
			GUI_DispStringAt(buf,100,100);
			
		}
	}


///////////////////////////////////////////////////////////////////

    while(1)
    {
    }
}

/******************************************************************/
